# class cat:
#     def eat(self):
#         # print(f'self:{id(self)}')
#         print(f'小猫{self.name},{self.age}岁爱吃鱼')
#
#     def drink(self):
#         print(f'小猫{self.name},{self.age}岁要喝水')
#
#
# tom = cat()
# # print(f'tom :{id(tom)}')
# tom.name = '汤姆'
# tom.age = 12
# tom.eat()
# tom.drink()
#
# blue_cat = cat()
# # print(f'blue:{id(blue_cat)}')
# blue_cat.name = '蓝猫'
# blue_cat.age =13
# blue_cat.eat()
# blue_cat.drink()

# class Cat:
#     """init 方法，创建对象后，会自动调用"""
#
#     def __init__(self, name, age):
#         # print('我是init方法，我被调用了')
#         self.name = name
#         self.age = age
#
#     def __str__(self):
#         return f'姓名：{self.name}，年龄：{self.age}'
#
#     def eat(self):
#         print(f'小猫{self.name},{self.age}岁爱吃鱼!')
#
#
# tom = Cat('tom', 12)
# tom.eat()
# print(tom)
# print(dir(tom))
#
# blue_cat = Cat('蓝猫', 6)
# blue_cat.eat()
# print(blue_cat)

# class Person:
#     def __init__(self, name, weight):
#         self.name = name
#         self.weight = weight
#
#     def __str__(self):
#         return f'姓名：{self.name}，体重：{self.weight}kg'
#
#     def run(self):
#         self.weight = self.weight - 0.5
#         print(f'{self.name}跑步了，体重减少了0.5kg，目前体重：{self.weight}kg')
#
#     def eat(self):
#         self.weight = self.weight + 1
#         print(f'{self.name}吃东西了，体重增加了1kg，目前体重：{self.weight}kg')
#
#
# if __name__ == '__main__':
#
#     ming = Person('小明', 45.2)
#     ming.run()
#     ming.eat()
#     ming.eat()
#
#     xmei = Person('小美',50)
#     xmei.run()
#     xmei.eat()
#     xmei.eat()

# class LoginPage:
#     def __init__(self, username, pwd, captcha):
#         self.username = username  # 用户名
#         self.pwd = pwd  # 密码
#         self.captcha = captcha  # 验证码
#
#     def login(self):
#         print(f'1.输入用户名：{self.username}')
#         print(f'2.输入密码：{self.pwd}')
#         print(f'3.输入验证码：{self.captcha}')
#         print('4.点击登录')
#
#
# if __name__ == '__main__':
#     admin = LoginPage('admin','123456','8888')
#     admin.login()


# class LoginPage:
#     def __init__(self, username, pwd, captcha):
#         self.username = username
#         self.pwd = pwd
#         self.captcha = captcha
#
#     def login(self):
#         print(f'输入用户名：{self.username}')
#         print(f'输入密码：{self.pwd}')
#         print(f'输入验证码：{self.captcha}')
#         print('点击登录')
#
#
# if __name__ == '__main__':
#     denglu = LoginPage('admin', '123456', '8888')
#     denglu.login()

# class HouseItem:
#     def __init__(self, name, area):
#         self.name = name
#         self.area = area
#
#     def __str__(self):
#         return f'{self.name}占地面积:{self.area}平米'
#
#
#
# class House:
#     def __init__(self, h_name,area):
#         self.h_name = h_name
#         self.total_area = area  # 总面积
#         self.free_area = area   # 剩余面积
#         self.item_list = []
#
#     def __str__(self):
#         return f'{self.h_name},总面积:{self.total_area}平米,剩余面积:{self.free_area}平米,家具:{self.item_list}'
#
#     def add_item(self, item):
#         """添加家具，item 家具对象"""
#         if self.free_area > item.area:
#             print(f'添加家具:{item.name}')
#             self.item_list.append(item.name)
#             self.free_area -= item.area
#         else:
#             print('房子面积不足，换个大房子吧')
#
# if __name__ == '__main__':
#     bed = HouseItem('席梦思',4)
#     chest = HouseItem('衣柜',2)
#     table = HouseItem('餐桌',1.5)
#     # print(bed)
#     # print(chest)
#     # print(table)
#     house = House('三室一厅',100)
#     house.add_item(bed)
#     print(house)
#     house.add_item(chest)
#     print(house)
#     house.add_item(table)
#     print(house)
#     # ABC = bed
#     # print(ABC)


# class HouseInfo:
#     def __init__(self, name, area):
#         self.name = name
#         self.area = area
#
#     def __str__(self):
#         return f'{self.name}占地面积:{self.area}平米'
#
#
# class House:
#     def __init__(self, name, area):
#         self.name = name
#         self.total_area = area
#         self.residual_area = area
#         self.furniture_list = []
#
#     def __str__(self):
#         return f'{self.name},总面积{self.total_area}平米,剩余面积{self.residual_area}平米,家具:{self.furniture_list}'
#
#     def add_item(self, item):
#         if self.total_area > item.area:
#             print(f'添加家具{item.name}')
#             self.furniture_list.append(item.name)
#             self.residual_area = self.residual_area - item.area
#         else:
#             print('添加失败，换个房子')
#
#
# if __name__ == '__main__':
#     bed = HouseInfo('席梦思', 4)
#     print(bed)
#     abc = House('三室一厅', 100)
#     print(abc)
#     abc.add_item(bed)
#     print(abc)


# class Student:
#     def __init__(self, name, age):
#         self.name = name
#         self.age = age
#
#     def __str__(self):
#         return f'姓名:{self.name},年龄{self.age}岁'
#
#     def eat(self):
#         print(f'{self.name}要吃饭')
#
#     def sleep(self):
#         print(f'{self.name}要睡觉')
#
#     def year(self):
#         print(f'{self.name}过年后就{self.age + 1}岁了')
#
#
# if __name__ == '__main__':
#     xming = Student('小明', 18)
#     print(xming)
#     xming.eat()
#     xming.sleep()
#     xming.year()
#     xmei = Student('小美', 17)
#     print(xmei)

# class Fruit:
#     def __init__(self, name, color, price):
#         self.name = name
#         self.color = color
#         self.price = price
#
#     def show(self):
#         print(f'水果名称:{self.name},颜色:{self.color},价格:{self.price}')
#
#
# if __name__ == '__main__':
#     apple = Fruit('苹果', '红色', 3.5)
#     apple.show()
#     watermelon = Fruit('西瓜','红色',1.9)
#     watermelon.show()

# class Computer:
#     def __init__(self, brand, price):
#         self.brand = brand
#         self.price = price
#
#     def play_movie(self, movie_name):
#         print(f'{self.brand}电脑播放{movie_name}')
#
#
# if __name__ == '__main__':
#     xmi = Computer('小米', 1500)
#     xmi.play_movie('葫芦娃')
#     mac = Computer('苹果', 5000)
#     mac.play_movie('变形金刚')


# class Animal:
#     def __init__(self, name, age):
#         self.name = name
#         self.age = age
#
#     def eat(self):
#         print(f'{self.name}吃东西')
#
#     def sleep(self):
#         print(f'{self.name}睡觉')
#
#
# class Cat(Animal):
#
#     def catch(self):
#         print(f'{self.name}会抓老鼠')
#
#
# class Dog(Animal):
#     def look_the_door(self):
#         print(f'{self.name}正在看家')
#
#
# if __name__ == '__main__':
#     tom = Animal('汤姆', 3)
#     tom.eat()
#     tom.sleep()
#     cat = Cat('黑猫警长', 4)
#     cat.catch()
#     dog = Dog('旺财',6)
#     dog.eat()
#     dog.sleep()
#     dog.look_the_door()


# class Dog:
#
#     def eat(self):
#         print('小狗睡觉')
#         print('小狗汪汪叫')
#
# class Xtq(Dog):
#     def eat(self):
#         super().eat()
#         print('哮天犬不爱睡觉')
#         print('哮天犬嗷嗷叫')
#
# class Cat(Dog):
#     pass
#
# if __name__ == '__main__':
#
#     xtq = Xtq()
#     xtq.eat()

# class Dog:
#     def game(self):
#         print('简单的玩耍')
#
#
# class XTQ(Dog):
#     def game(self):
#         print('哮天犬在天上玩耍')
#
#
# class Person:
#
#     def play_dog(self, dog):
#         print('人和狗在玩耍',end =' ')
#         dog.game()
#
#
# if __name__ == '__main__':
#     dog = Dog()
#     ren = Person()
#     ren.play_dog(dog)
#
#     xtq = XTQ()
#     ren1 = Person()
#     ren1.play_dog(xtq)

# class Person:
#     def __init__(self, name, age):
#         self.name = name
#         self.__age = age
#
#     def __str__(self):
#         return f'{self.name},{self.__age}'
#
#     def set_age(self, age):
#         if age < 0 or age > 120:
#             print('提供的年龄信息不对')
#             return
#         self.__age = age
#
#
# if __name__ == '__main__':
#     xwang = Person('小王', 22)
#     print(xwang)
#     xwang.__age = 23
#     print(xwang)
#     xwang.set_age(1000)
#     print(xwang)


# class Tool:
#
#     count = 0
#     def __init__(self,name):
#         self.name = name
#         Tool.count += 1
#
#
#     @classmethod
#     def show_tool(cls):
#         return cls.count
#
#
# if __name__ == '__main__':
#     print(Tool.show_tool())
#     tool1 = Tool('扳手')
#     print(Tool.count)
#     tool2 = Tool('锤子')
#     print(Tool.show_tool())
#     print(tool1.show_tool())
#     print(tool2.show_tool())

import random


# class Game:
#     top_score = 0  # 定义类属性，保存历史最高分
#
#     def __init__(self, naem):  # 实例属性
#         self.play_naem = naem
#
#
#     @staticmethod  # 静态方法
#     def show_help():
#         print("这是游戏的帮助信息")
#
#     @classmethod  # 类方法
#     def show_top_score(cls):
#         print(f'历史最高分： {cls.top_score}')
#
#     def start_game(self):
#         a = random.randint(10, 100)
#         print(f'本次玩家 {self.play_naem} 得分：{a}')
#         if a > Game.top_score:
#             Game.top_score = a
#
# if __name__ == '__main__':
#     Game.show_help()
#     Game.show_top_score()
#     xwang = Game('小王')
#     xwang.start_game()
#     xmei = Game('小美')
#     xmei.start_game()
#     Game.show_top_score()


# class Geam:
#     top_score = 0
#
#     def __init__(self, player_name):
#         self.player_name = player_name
#
#     @staticmethod
#     def show_help():
#         print('这是游戏的帮助信息')
#
#     @classmethod
#     def show_top_score(cls):
#         print(f'历史最高分：{cls.top_score}')
#
#     def staer_game(self):
#         max = random.randint(1, 100)
#         print(f'本次玩家 {self.player_name} 得分：{max}')
#         if max > Geam.top_score:
#             Geam.top_score = max
#
# if __name__ == '__main__':
#     Geam.show_help()
#     Geam.show_top_score()
#     xwang = Geam('小王')
#     xwang.staer_game()
#     xmei = Geam('小美')
#     xmei.staer_game()
#     Geam.show_top_score()

# class Geam:
#     score = 0
#     name1 = ''
#     def __init__(self,name):
#         self.name = name
#
#     @staticmethod
#     def help1():
#         print('查看游戏的帮助信息')
#
#     @classmethod
#     def fraction(cls):
#         print(f'{cls.name1}当前的最高分:{cls.score}')
#
#     def game(self):
#         max = random.randint(1,100)
#         print(f'玩家 {self.name} 分数 {max}')
#         if max > Geam.score:
#             Geam.score = max
#             Geam.name1 = self.name
# print(f'玩家 {self.name} 分数 {max} ')


# if __name__ == '__main__':
#     Geam.help1()
#     Geam.fraction()
#     xwang = Geam('小王')
#     xwang.game()
#     xmei = Geam('小美')
#     xmei.game()
#     xzhang = Geam('小张')
#     xzhang.game()
#     Geam.fraction()

# class Animal:
#     def __init__(self, name):
#         self.name = name
#
#     def eat(self):
#         print('吃肉')
#
#     def drink(self):
#         print('喝水')
#
#     def sleep(self):
#         print('睡觉')
#
# class Dog(Animal):
#     def bark(self):
#         print('汪汪叫')
#
# if __name__ == '__main__':
#     xgou = Dog('小狗')
#     xgou.eat()
#     xgou.drink()
#     xgou.sleep()
#     xgou.bark()


# class Person:
#     def __init__(self, name, age):
#         self.name = name
#         self.__age = age
#
#     def get_age(self):
#         return self.__age
#
#     def set_age(self, nuw_age):
#         if 0 < nuw_age < 120:
#             self.__age = nuw_age
#         else:
#             print('输入不正确')
#
#     def __str__(self):
#         return f'姓名：{self.name} 年龄：{self.__age}'
#
#
# if __name__ == '__main__':
#     xwang = Person('小王', 22)
#     # print(xwang.get_age())
#
#     print(xwang)
#     print(xwang.get_age())
#     xwang.set_age(33)
#     print(xwang)
#     print(xwang.get_age())
#     xwang.name ='小李'
#     print(xwang)


# with open('test.txt','w',encoding = 'utf-8') as f:
#      a = f.write('wow,so beautiful!')
#      print(a)
#      f.close()
#      print(a)

# f = open('tset.txt','w',encoding='utf-8')
# a = f.write('wow,so beautiful!')
# f.close()
#
#
# f = open('tset.txt','r',encoding='utf-8')
# print(f.read())

# with open('a.txt','w',encoding='utf-8') as f:
#     f.write('张三,李四,王五,赵六')
#     f.close()
#
# f = open('a.txt','r',encoding='utf-8')
# data = f.read()
# my_list = data.split(',')
# f.close()
# print(my_list)

# with open('b.txt','w',encoding='utf-8') as f:
#     f.write('1*2*3*4*5*6*7')
#     f.close()
# f = open('b.txt','r',encoding='utf-8')
# data = f.read()
# data = data.split('*')
# print(data)
# new = 0
# for i in data:
#     new = new + int(i)
# print(new)




